package com.anyview.controller;


import com.anyview.service.ExcelTestService;
import com.anyview.vo.DownloadExcelVo;
import com.anyview.vo.Result;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;


/**
 * excel操作
 */
@RestController
@RequestMapping("/excelTest")
public class ExcelTestController {


    @Resource
    private ExcelTestService excelTestService;

    /**
     * 根据时间查看订单消息信息
     *
     * @param downloadExcelVo 前端数据
     * @return 返回excel文件
     */
    @GetMapping
    public ResponseEntity<byte[]> downloadExcelBetweenDate(@RequestBody DownloadExcelVo downloadExcelVo) {

        return excelTestService.downloadExcelBetweenDate(downloadExcelVo);
    }


    /**
     * 将数据保存进数据库中
     *
     * @param file 文件
     * @return 返回响应结果
     */
    @PostMapping
    public Result<Boolean> excelImportDatabase(MultipartFile file) throws IOException {
        return excelTestService.excelImportDatabase(file);
    }


}
